const app = getApp();
const db = wx.cloud.database();
Page({
  data: {
    wordTools: [
      {
        "name": "背单词",
        "icon": "/image/tool/dictionary.jpg",
        "url": "/pages/study/recite/recite-index?type=word&title=背单词",
        "bg_color": "bg_color_1"
      },
      {
        "name": "背词组",
        "icon": "/image/tool/dictionary.jpg",
        "url": "/pages/study/recite/recite-index?type=phrase&title=背词组",
        "bg_color": "bg_color_2"
      },
      {
        "name": "背词根",
        "icon": "/image/tool/dictionary.jpg",
        "url": "/pages/study/recite/recite-index?type=root&title=背词根",
        "bg_color": "bg_color_3"
      }

    ],
    categoryList: []
  },

  onLoad: function(options) {

    let that = this;

    let cacheList = wx.getStorageSync("cacheList");
    if (cacheList) {
      that.setData({
        categoryList: cacheList
      });
    }

    //查询视频类型 
    db.collection('article_category').get().then(res => {
      console.info(res);
      that.setData({
        categoryList: res.data
      });

      wx.setStorageSync("cacheList", res.data);
    })
  },
  onShareAppMessage: function () {

  }
});